﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="frmMainNew.aspx.cs" Inherits="frmMainNew" %>

<%@ Import Namespace="Business" %>
<%@ Register Src="~/UserControls/ucFirstMenu.ascx" TagPrefix="uc1" TagName="ucFirstMenu" %>


<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>信息管理系统界面</title>
    <link rel="stylesheet" href="css/Framestyle.css" type="text/css" />
    <link rel="stylesheet" id="Link1" type="text/css" href="css/ui-cupertino/easyui.css" />
    <link rel="stylesheet" type="text/css" href="css/icon.css" />
    <script type="text/javascript" src="ScriptFile/jquery.js"></script>
    <script type="text/javascript" src="ScriptFile/jquery.easyui.min.js"></script>

    <script type="text/javascript">

        //显示进度条
        function ShowLoading() {
            //定时器2秒
            $.messager.progress({
                title: '请稍候',
                msg: '数据加载中...'
            });

        }

        //隐藏进度条
        function HideLoading() {
            $.messager.progress('close');

            //$("#loadbox").hide();
        }

        ////控制右侧区域的展开和折叠
        //function ctrlRegion(nType, strRegion) {
        //    strAction = "";
        //    if (nType == 1) {
        //        //隐藏east侧区域
        //        if (strAction == "expand") {
        //            $('#divBody').layout('collapse', strRegion); //折叠
        //            strAction = "collapse";
        //        }
        //    }
        //    else {
        //        if (strAction == "collapse") {
        //            $('#divBody').layout('expand', strRegion); //展开
        //            strAction = "expand";
        //        }
        //    }
        //}

        //消息框
        function loadMsg(strMsg) {
            $.messager.show({
                title: '待办事项(5秒后自动关闭)',
                msg: strMsg,
                timeout: 5000,
                showType: 'slide'
            });
        }

        //设置标题头
        function loadTitle(strId, strTile) {
            $("#" + strId).panel({ title: strTile });
        }

        //关闭窗口
        function CloseDivDlg() {
            $('#dlgConfig').window('close');
        }

        //打开内嵌网页的通用方法1（window）
        function openDivDlg(strTitle, strUrl) {
            //增加参数queryid
            var divWidth = 800;
            var divHeight = 600;

            $('#dlgConfig').window({
                title: strTitle, width: divWidth, height: divHeight
            });

            $('#iframeConfig').attr("src", strUrl);

            // $('#dlgConfig').window({ maximized: true });
            $('#dlgConfig').window('open');
        }

        //改变样式
        function changeSkin() {
            $('#skin a').click(function () {
                $("#" + this.id).addClass("selected").siblings().removeClass("selected");
                $('#skinCss').attr("href", "css/" + (this.id) + "/easyui.css");
            });
        }
         
    </script>
</head>
<body class="easyui-layout" id="Body1" style="height: 100%;">
    <script type="text/javascript">
        var isTabShow = '<%=IsTabShow%>';
        //子菜单点击
        function addTab(obj, strUrl, strTitle) {
            $("#divAccordion .panel .panel-body div").siblings().removeClass("divactive");
            //$(obj).parent().siblings().removeClass("divactive");
            $(obj).parent().addClass("divactive");
            ShowLoading();
            if (isTabShow == "True") {
                //显示进度条
                var varTemp = $("#divMain").tabs("exists", strTitle);
                if (varTemp == false) {
                    $('#divMain').tabs('add', {
                        title: strTitle,
                        content: '<iframe src="' + strUrl + '" width="99%" height="99%" frameboder="0" id="' + strTitle + '"></iframe>',
                        iconCls: 'icon-save',
                        closable: true
                    });

                    //为子框架添加加载事件
                    $("#" + strTitle).load(function () {
                        HideLoading();
                    });
                }
                else {//如果已经存在则选中对应的选项卡并刷新
                    if (strUrl.indexOf("?") > 0) {
                        strUrl += "&rdm=" + Math.random();
                    }
                    else {
                        strUrl += "?rdm=" + Math.random();
                    }
                    $("#" + strTitle + "").attr("src", strUrl);
                    $('#divMain').tabs('select', strTitle);
                    //再关闭一次
                    HideLoading();
                }
            } else {
                if(strUrl.indexOf("?")>0) {
                    strUrl = strUrl + "&ran="+Math.random();
                }
                else {
                    strUrl = strUrl + "?ran=" + Math.random();
                }
                $("#iframeMain").attr("src", strUrl);
                HideLoading();
            }
        }

        function getWaitWorkCount() {
            $.post("AjaxProcess/AjaxGetWaitWorkCnt.ashx", function (data) {
                var jsonObj = $.parseJSON(data);
                $("#waitWorkCount").text(jsonObj.WaitWorkCount);
            });
        }

        function OpenMenuUrl(strUrl)
        {
            $("#iframeMain").attr("src", strUrl);
            HideLoading();
        }

        $(function () {
            var height = $(document).height() - 127;
            $("#divwest").height(height);
            $("#divCenter").height(height);
            changeSkin();
            $('#divBody').layout('collapse', 'east');
            
            if (isTabShow != "True") {
                $("#divMain").hide();
            }
            var arrMenu = new Array();
            //顶部导航切换
            $(".nav li a").click(function () {
                $(".nav li a.selected").removeClass("selected");
                $(this).addClass("selected");
                var firstMenuName = $(this).find('h2').text();
                $.post("AjaxProcess/AjaxGetLeftMenu.ashx?firstMenuName=" + encodeURI(firstMenuName), function (data) {
                    if (data == "UserId为空") {
                        window.location.href = "Default.aspx";
                        return;
                    }
                    for (var menuIndex in arrMenu) {
                        $('#divAccordion').accordion("remove", arrMenu[menuIndex]);
                    }
                    arrMenu = [];
                    var jsonObj = $.parseJSON(data);
                    $.each(jsonObj, function (index, item) {
                        var html = "";
                        $.each(item.ChildMenus, function (idx, child) {
                            var url = "<%=SystemConfig.NewActivexAppearUrl%>";
                            var href = child.LinkHref.replace("{CjFlowPage}", url);
                            var userid = "<%=UserId%>";
                            href = href.replace("{userid}", userid);
                            html += "<div  id='divChild" + index + idx + "'style='height: 30px; line-height: 30px;vertical-align:middle;display:block;'><cite class='cite'></cite><a href='#' style='display:inline-block;' onclick=\"addTab(this,'" + href + "','" + child.MenuChildDesc + "');\" title='" + child.MenuChildDesc + "'>" + child.MenuChildDesc + "</a><i></i></div>";
                        });
                        var isSelected = false;
                        if (index == 0) {
                            isSelected = true;
                        }
                        var icon = item.PicPath == "" ? "icon-leftico01" : item.PicPath;
                        $('#divAccordion').accordion('add', {
                            title: item.MenuParentDesc,
                            content: html,
                            selected: isSelected,
                            iconCls: icon
                        });
                        arrMenu.push(item.MenuParentDesc);
                    });
                });
            });

            $(".nav li a:first").trigger("click");
            setTimeout('$(".panel-body>div>a:first").click();', 1000);
            $("#about").click(function () {
                //$(".panel-body>div>a:first").click();
            });
            getWaitWorkCount();
            setInterval(getWaitWorkCount, 60000);
        });
    </script>
    <form id="form1" runat="server">
        <div id="div1" region="north" split="false" style="height: 90px; margin: 0px; padding: 0px; background: url(images/topbg.gif) repeat-x;">
            <div class="topleft">
                <a href="Main.aspx"> <img src="images/glxxzx_top.png" title="系统首页"  /> </a>
            </div>
            <uc1:ucFirstMenu runat="server" id="ucFirstMenu" />
            <div class="topright">
                <ul>
                    <li><span>
                        <img src="images/help.png" title="帮助" class="helpimg" /></span><a href="#">帮助</a></li>
                    <li><a href="#" id="about">关于</a></li>
                    <li><a href="Default.aspx" target="_parent">退出</a></li>
                </ul>
                <div class="user">
                    <span><%=Session["UserName"] %></span>
                    <i>待办事项</i>
                    <a href="javascript:OpenMenuUrl('MyWindow/TaskInStepList.aspx')"><b id="waitWorkCount">0</b></a>
                </div>
            </div>
        </div>
        <div id="divwest" region="west"  title='功能导航' split="true" minWidth="170" maxWidth="250" style="width: 193px; background: #f0f9fd;">
            <div id="divAccordion" class="easyui-accordion" border="false" fit="true" style="background: #f0f9fd;">
            </div>
        </div>
        <div id="divCenter" region="center"  title="业务办公区" style="overflow: hidden;">
            <div id="divMain" class="easyui-tabs"  fit="true" border="false" style="overflow: hidden; background-color: #ECF2FB;">
            </div>
            <iframe id="iframeMain" scrolling="auto" frameborder="0" src="" style="width: 100%; height: 100%;"></iframe>
        </div>
    </form>
</body>
</html>

